home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
util
/
misc
/
IntuiCookie12.lha
/
IntuiCookie
/
additional
/
cookhash.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-14
|
953b
|
52 lines
/* cookhash - read a sayings file and generate an index file
* by Karl Lehenbauer (karl@sugar.uu.net, uunet!sugar!karl)
* cookhash.c 1.1 1/12/89
*/
#include <stdio.h>
#include <stdlib.h>
#define YES 1
#define NO 0
#define METACHAR '%'
main(int argc,char *argv[])
{
int c, sawmeta=0;
long charpos = 0;
if (argc != 1)
{
fprintf(stderr,"usage: cookhash <cookiefile >hashfile\n");
exit(1);
}
/* write out the "address" of the first cookie */
puts("000000");
/* read the cookie until the end,
* whenever the end-of-cookie ("%%") sequence is found,
* the "address" (file position) of the first byte following
* it (start of next cookie) is written to the index (hash) file
*/
while ((c = getchar()) != EOF)
{
if (c == METACHAR)
{
if (sawmeta)
{
printf("%06lx\n",charpos+2);
sawmeta = NO;
}
else
sawmeta = YES;
}
else
sawmeta = NO;
charpos++;
}
exit(0);
}
/* end of cookhash.c */